
*this program does not use absolute paths
*it assumes that upon starting Stata, the user sets working directory 

*the processed_data was created by creating variables.do
use processed_data,clear
**Table 1: Data Description
**Table 2: Descriptive Statistics
summ imr dimr uswheat_aid lnfaid avg_fap l.uswheat_prod inst1 intrstate_war rainshock lnpop

**Table 3: First Stage Regressions of Wheat Aid
reg lnfaid uswheat_prod inst1 avg_fap lnpop , r
outreg2 using table3 , replace ti(First Stage Regressions Wheat Aid) stats(coef tstat) lab

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop , r
outreg2 using table3, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop rainshock , r
outreg2 using table3, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock , r
outreg2 using table3, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop ll.rainshock , r
outreg2 using table3, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop rainshock l.rainshock , r
outreg2 using table3, stats(coef tstat) word


**Table 4: First Stage Regressions of Wheat Aid with Conflict
reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock intensity , r
outreg2 using table4, replace ti(First Stage Regressions Wheat Aid with Conflict) stats(coef tstat) lab

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intensity , r
outreg2 using table4, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock intrstate_war , r
outreg2 using table4, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war , r
outreg2 using table4, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock onset , r
outreg2 using table4, stats(coef tstat)

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.onset , r
outreg2 using table4, stats(coef tstat) 

reg lnfaid l.uswheat_prod inst1 avg_fap lnpop l.rainshock unvotes , r
outreg2 using table4, stats(coef tstat) word


**Table 5: Second Stage Regressions of IMR
ivregress 2sls dimr (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock ) , r
outreg2 using table5, replace ti(Second Stage Regressions) stats(coef tstat) lab

ivregress 2sls dimr lnpop (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock) , r
outreg2 using table5, stats(coef tstat)

ivregress 2sls dimr lnpop rainshock (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock) , r
outreg2 using table5, stats(coef tstat)

ivregress 2sls dimr lnpop l.rainshock (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock) , r
outreg2 using table5, stats(coef tstat)

ivregress 2sls dimr lnpop rainshock l.rainshock (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock) , r
outreg2 using table5, stats (coef tstat) word


**Table 6: Second Stage Regressions of IMR with War
ivregress 2sls dimr lnpop (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, replace ti(Second Stage Regressions with War Variables) stats(coef tstat) lab

ivregress 2sls dimr lnpop intrstate_war (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, stats(coef tstat)

ivregress 2sls dimr lnpop l.intrstate_war (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, stats(coef tstat)

ivregress 2sls dimr lnpop any_war (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, stats(coef tstat)

ivregress 2sls dimr lnpop l.any_war (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, stats(coef tstat)

ivregress 2sls dimr lnpop intensity (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, stats(coef tstat)

ivregress 2sls dimr lnpop l.intensity (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) , r
outreg2 using table6, stats(coef tstat) word 


**Table 7:Wheat Aid and IMR IV Estimates
 set more off, perm 

*population
ivregress 2sls dimr lnpop (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war)
estat first 
local fstat = r(mineig)
estat overid
outreg2 using  table7, replace ti(Table11:  Test of Strength and Valididty of Instrument) stats(coef tstat) /*
*/addstat(Overid p-value, r(p_sargan),First stage F-stat, `fstat')

*rainshock 
ivregress 2sls dimr lnpop rainshock l.rainshock (lnfaid = l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war) 
estat first 
local fstat = r(mineig)
estat overid
outreg2 using  table7, stats(coef tstat) addstat(Overid p-value, r(p_sargan),First stage F-stat, `fstat')

* Conflict
ivregress 2sls dimr lnpop intrstate_war l.intrstate_war intensity l.intensity (lnfaid= l.uswheat_prod inst1 avg_fap lnpop l.rainshock l.intrstate_war)
estat first
local fstat= r(mineig)
estat overid
outreg2 using table7, stats(coef tstat) addstat(Overid p-value, r(p_sargan), First stage F-stat,`fstat' ) word


**Table 8:Effects of Placebo Instruments on IMR
ivregress 2sls dimr lnpop avg_fap (lnfaid = l.uswheat_prod inst1 avg_fap lnpop) , r
outreg2 using table8 , replace ti(Effect of Placebo Instruments on IMR) stats(coef tstat) lab

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Cabbages cabbage avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat) 

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Carrots_turnips carrots_turnips avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Cotton_lint cotton_lint avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Grapefruit grapefruit avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Grapes grapes avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Lettuce lettuce avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Onions_dry onions_dry avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Oranges oranges avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Peaches_nectarines peaches_nectarines avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat)

ivregress 2sls dimr lnpop avg_fap (lnfaid = USprod_Watermelons watermelons avg_fap lnpop) , r
outreg2 using table8, stats(coef tstat) word
